//
//  HLTempNavigationController.swift
//  MyBlog
//
//  Created by 李芙蓉 on 16/3/4.
//  Copyright © 2016年 hanlei. All rights reserved.
//

import UIKit

class HLTempNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    //重载pushViewController方法
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        
        //如果childViewController == 0 标示控制器是最初的控制器
        if childViewControllers.count > 0 {
            
            //如果childViewController == 1 标示控制器是第一个push出来的控制器
            if childViewControllers.count == 1 {
                
            }
            
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "返回", imageName: "navigationbar_back_withtext", target: self, action: "backButtonDidClick")
        }
        
        super.pushViewController(viewController, animated: animated)
    }
    
    @objc private func backButtonDidClick () {
        
        popViewControllerAnimated(true)
    }
    
}
